package wxapp

import (
	"context"
	"github.com/gogf/gf/v2/util/gconv"
	"hotgo/internal/dao"
	"hotgo/internal/model/input/sysin"
)

// Lunbo 首页轮播图接口
func (s *sWxapp) Lunbo(ctx context.Context) (list *[]sysin.LunboListModel, err error) {
	list = &[]sysin.LunboListModel{}
	res, err := dao.Lunbo.Ctx(ctx).OrderAsc("sort").All()
	err = gconv.Struct(res, list)
	return
}

// HotList 热门赛事列表
func (s *sWxapp) HotList(ctx context.Context, page int, pageSize int) (list *[]sysin.HotmatchListModel, totalCount int, err error) {
	totalCount, err = dao.Hotmatch.Ctx(ctx).Page(page, pageSize).OrderDesc("id").Count()
	if err != nil {
		return
	}
	res, err := dao.Hotmatch.Ctx(ctx).Page(page, pageSize).OrderDesc("id").All()
	if err != nil {
		return
	}
	err = gconv.Structs(res, &list)
	return
}
